<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="lib/react.development.js"></script>
    <script src="lib/react-dom.development.js"></script>
    <script src="lib/babel.min.js"></script>
    <script src="lib/prop-types.min.js"></script>
</head>
<body>
    <div id="root"></div>
    <script type="text/babel">
        let {Component} = React
        class Demo extends Component{
            constructor(){
                super()
                this.state = {
                    selectVal:'ccc',
                    selectArr:['aaa','bbb','ccc','ddd','eee']
                }
            }

            handleChange = (ev) =>{
                this.setState({
                    selectVal:ev.target.value
                })
            }
            handleSubmit = (ev)=>{
                let {selectVal} = this.state;
                console.log(selectVal)
                ev.preventDefault();
            }

            render(){
                return (
                    <div>
                        <form onSubmit={this.handleSubmit}>
                            <select value={this.state.selectVal} onChange={this.handleChange}>
                                {
                                    this.state.selectArr.map((val,index)=>
                                        <option key={index} value={val}>{val}</option>
                                    )
                                }
                            </select>
                            <button>提交</button>
                        </form>
                    </div>
                )
            }
        }

        ReactDOM.render(
            <Demo />,
            document.querySelector("#root")
        )

    </script>
</body>
</html>